# Copyright 2006 Devils-Hawk
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils git toolchain-funcs

EGIT_REPO_URI="git://git.xmms.se/xmms2/xmms2-devel.git"
EGIT_TREE="master"
EGIT_PROJECT="xmms2-devel"

S="${WORKDIR}/${EGIT_PROJECT}"

DESCRIPTION="XMMS2 Git Version"
HOMEPAGE="http://wiki.xmms2.xmms.se/"
LICENSE="LGPL-2.1 / GPL"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="alsa jack oss java python ruby avahi vorbis wma mp3 aac flac gnome musepack samba modplug speex id3 daap curl sid ecore mms icecast"

RDEPEND=">=dev-libs/glib-2.6.0
	>=dev-db/sqlite-3.2.6
	dev-libs/boost
	aac? ( >=media-libs/faad2-2.0 )
	alsa? ( media-libs/alsa-lib )
	curl? ( >=net-misc/curl-7.11.2 )
	ecore? ( x11-libs/ecore )
	ruby? ( dev-lang/ruby )
	java? ( virtual/jdk )
	samba? ( net-fs/samba )
	python? ( >=dev-lang/python-2.2.1 >=dev-python/pyrex-0.9.3 )
	modplug? ( media-libs/libmodplug )
	musepack? ( >=media-libs/libmusepack-1.1 )
	vorbis? ( media-libs/libvorbis
		  media-libs/libogg )
	flac? ( media-libs/libvorbis
		>=media-libs/flac-1.1.2 )
	jack? ( >=media-sound/jack-0.100.0 )
	mp3? ( media-libs/libmad )
	speex? ( >=media-libs/libogg-1.1
		 media-libs/speex )
	daap? ( >=media-libs/libopendaap-0.3.0 )	
	avahi? ( >=net-dns/avahi-0.6 )
	gnome? ( >=gnome-base/gnome-vfs-2.0 )
	sid? ( media-sound/sidplay media-libs/resid )
	wma? ( media-video/ffmpeg )
	mms? ( media-libs/libmms )
	"
DEPEND="${RDEPEND}
	dev-util/pkgconfig
	>=dev-lang/python-2.2.1
	>=dev-util/scons-0.96"

DISABLE=""

src_unpack() {
	git_src_unpack
	cd "${S}"
	sed -i -e "s:/lib:/$(get_libdir):g" SConstruct xmms2.pc.in xmmsenv.py
}

src_compile() {
		local u o
		for u in aac:faad alsa curl ecore gnome:gnomevfs modplug flac \
			 jack mp3:mad musepack oss ruby samba sid speex  \
	                 vorbis daap id3:id3v2 avahi:mdns java wma mms \
			 python icecast:icymetaint; do
		o=${u##*:} ; o=${o:-${u}}
		u=${u%%:*}
		use ${u} || DISABLE="${DISABLE} ${o}"
	        done

		echo "Disabling: ${DISABLE}"

		scons \
		CC=$(tc-getCC) \
		CXX=$(tc-getCXX) \
		CCFLAGS="${CFLAGS}" \
		CXXFLAGS="${CXXFLAGS}" \
		LINK=$(tc-getCC) \
		PREFIX="/usr" \
		MANDIR="/usr/share/man" \
		INSTALLDIR=${D} \
		CONFIG="yes" \
		EXCLUDE="${DISABLE}" || die "Scons failed!"
}

src_install() {
		scons install || die "Scons install failed!"
		dodoc AUTHORS ChangeLog README
}

